﻿<%@ Page Title="" Language="C#" MasterPageFile="~/RealState.Master" AutoEventWireup="true" CodeBehind="Edit_Account.aspx.cs" Inherits="WebApplication.ManageAccount.Edit_Account1" EnableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
 <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $('#<%=ddlCity.ClientID%>').attr("disabled", true);
            $('#<%=ddlCountry.ClientID%>').change(getCity);
            $('#<%=ddlCountry.ClientID%>').change(getCountryCode);
            $('#<%=ddlCity.ClientID%>').append(new Option('City', 'City', false));
            $(":input[title]").each(function () {
                $(this).val($(this).attr("title"));
                $(this).bind('focus', function () {
                    if ($(this).val() == $(this).attr("title")) $(this).val('');
                });
                $(this).bind('blur', function () {
                    if ($(this).val() == '') $(this).val($(this).attr("title"));

                });
            });
        });

        function getCity() {
            $('#<%=ddlCity.ClientID%>').attr("disabled", true);
            $("select[id$=ddlCity] > option").remove();
            $('#<%=ddlCity.ClientID%>').append(new Option('City', 'City', false));
            $.ajax({
                type: "POST",
                url: "CountryDetails.asmx/GetCity",
                data: "{Country: '" + $('#MainContent_ddlCountry').val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i];
                        var text = models[i];
                        $('#MainContent_ddlCity').append(new Option(text, val, false));
                    }
                    $('#<%=ddlCity.ClientID%>').attr("disabled", false);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                }

            });
        }
        function getCountryCode() {
            $.ajax({
                type: "POST",
                url: "CountryDetails.asmx/GetCountryCode",
                data: "{Country: '" + $('#MainContent_ddlCountry').val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var objectvalue = jQuery.parseJSON(response.d);
                    $('#MainContent_txt_CountryCode').val('00' + objectvalue);

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                }

            });
        }
        function CheckRequiredFields() {
            var FirstName = document.getElementById('MainContent_txt_FisrtName');
            var LastName = document.getElementById('MainContent_txt_LastName');
            var CountryCode = document.getElementById('MainContent_txt_CountryCode');
            var ContactInfo = document.getElementById('MainContent_txt_ContactInfo1e');
            var EmailID = document.getElementById('MainContent_txt_EmailID');
            if (FirstName.value == '' || LastName.value == '' || CountryCode.value == '' || ContactInfo.value == '' || EmailID.value == '') {
                return false;
            }
            return true;
        }
        function checkPageValidity() {

            var result = true;

            if (result = CheckRequiredFields()) {
                document.getElementById('div_error').style.display = "none";
                return true;
            }
            else {
                document.getElementById('div_error').style.display = "block";
                document.getElementById('msg_bx1').innerHTML = '* marked fields are required.';
                return false;
            }
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  <div id="content_container" style="margin-bottom: 0px !important;">
        <br />
        <!-- Admin Left Area Start -->
        <div class="admin-left">
            <ul>
                <li><a href="Account_Overview.aspx" class="active">My Account Overview</a></li>
                <li><a href="#">Manage Offers</a></li>
                <li><a href="#">Manage Requests</a></li>
            </ul>
        </div>
        <!-- Admin Left Area End -->
        <!-- Admin right area Start -->
        <div class="admin-right">
            <h1>
                Edit My Account</h1>
            <div class="error_box" id="div_error">
                <span class="fix_error" id="msg_bx1"></span>
                <br />
                <span class="error_description"></span>
            </div>
            <div id="div_UpdatePwdMsg" runat="server" style="display: none;">
                <h2 class="active_tick">
                    Your account details has been updated successfully.</h2>
            </div>
            <div class="sectionHeader">
                Account Information</div>
            <dl class="form clearfix">
                <dt>
                    <asp:TextBox ID="txt_FisrtName" runat="server" CssClass="form-text" TabIndex="1"></asp:TextBox>
                    <span class="red">*</span> </dt>
                <dt>
                    <asp:TextBox ID="txt_LastName" runat="server" CssClass="form-text" TabIndex="2"></asp:TextBox>
                    <span class="red">*</span> </dt>
                <dt>
                    <asp:DropDownList ID="ddlCountry" CssClass="form-text" runat="server" TabIndex="3">
                    </asp:DropDownList>
                    <span class="red">*</span> </dt>
                <dt>
                    <asp:DropDownList ID="ddlCity" CssClass="form-text" runat="server" TabIndex="4">
                    </asp:DropDownList>
                    <span class="red">*</span>
                    <br />
                </dt>
                <dt>
                    <asp:TextBox ID="txt_CountryCode" runat="server" CssClass="form-text" TabIndex="5"></asp:TextBox>
                    <span class="red">*</span> </dt>
                <dt>
                    <asp:TextBox ID="txt_ContactInfo1" runat="server" CssClass="form-text" TabIndex="6"></asp:TextBox>
                    <span class="red">*</span> </dt>
                <dt>
                    <asp:TextBox ID="txt_ContactInfo2" runat="server" CssClass="form-text" TabIndex="7"></asp:TextBox>
                </dt>
                <dt>
                    <asp:TextBox ID="txt_EmailID" runat="server" CssClass="form-text" TabIndex="9"></asp:TextBox>
                    <span class="red">*</span>
                   
                     </dt>
                <br />
                <asp:Button ID="btn_Update" Text="Update" runat="server" CssClass="reg-blue-round-btn w75"
                    TabIndex="9" OnClientClick="return checkPageValidity();" onclick="btn_Update_Click" 
                        />
                </dt>
            </dl>
        </div>
        <!-- Admin right area End -->
        <div class="clear">
        </div>
    </div> </div>  
</asp:Content>
